﻿using System.Windows;
using System.Windows.Controls;
using Microsoft.Extensions.DependencyInjection;
using Serilog;
using SimpleTool.Server;

namespace SimpleTool.ActivityUnit.EchoControl
{
    /// <summary>
    /// ProductRegisterUI.xaml 的交互逻辑
    /// </summary>
    public partial class ProductPreviewUI : UserControl
    {
        private readonly ILogger Logger = Log.ForContext<ProductPreviewUI>();
        private ActivityViewModel? HoldActivityViewModel = null;
        private Ruined? Ashbin = null;

        public ProductPreviewUI()
        {
            InitializeComponent();
            App MyApp = (App)Application.Current;
            HoldActivityViewModel = MyApp.ServiceProvider.GetRequiredService<ActivityViewModel>();
            Ashbin = new Ruined(this, () => {
                HoldActivityViewModel.HoldEmbeddedTreeStructures.Clear();
                Ashbin = null;
                HoldActivityViewModel = null;
                Logger.Print(RuntimeLog.LogType.Warning, "ProductPreviewUI is destory");
            });
            DataContext = HoldActivityViewModel;
        }
    }
}
